package bTree.LeetCode;

public class 等差数列划分 {
    public int numberOfArithmeticSlices(int[] nums) {
        int length = nums.length;
        int res=0;
        if (length<3){
            return 0;
        }
        int []dp=new int[length+1];
        for (int i=3;i<=length;i++){
            int num1 = nums[i - 3];
            int num2 = nums[i - 2];
            int num3 = nums[i - 1];
            if (num2-num1==num3-num2){
                dp[i]=dp[i-1]+1;
                res+=dp[i];
            }
        }
        return res;
    }
}